import React from "react";
import { useButton, RNAriaButtonProps } from "@react-native-aria/button";
import { Pressable, Text, View } from "react-native";
import { useRef } from "react";

export function Button(props: any) {
  const ref = useRef(null);
  let newProps: RNAriaButtonProps = {
    isDisabled: props.isDisabled ? props.isDisabled : false,
  } 

  // let { buttonProps, isPressed } = useButton( {...props});
  let { buttonProps, isPressed } = useButton({ ...newProps,
    ...props
  });


  return (
    <View>
      <Pressable
        ref={ref}
        {...buttonProps}
        style={{
          backgroundColor: isPressed ? "rgb(9, 90, 186)" : "#e1e1e1",
          padding: 5,
        }}
      >
        <Text
          style={{
            color: isPressed ? "#f1f1f1" : "#000",
          }}
        >
      A simple button {newProps.isDisabled ? "isDisabled true" : (isPressed ? "isPressed :true" : "isPressed :false")}

        </Text>
      </Pressable>
    </View>
  );
}
